import * as vscode from 'vscode';
import { CompletionItemConfig } from '../types/completion';

/**
 * Create a pre-configured CompletionItem
 * @param config The configuration options for the full item
 * @returns The completed vscode.CompletionItem instance
 * 
 * @example
 * ```ts
 * const config: CompletionItemConfig = {
 *     target
 *     title
 *     subtitle
 *     insertText
 *     kind: CompletionKinds.MODULE, // icon
 * };
 * const item = createCompletionItem(config);
 * ```
 */
export function createCompletionItem(config: CompletionItemConfig): vscode.CompletionItem {
    const item = new vscode.CompletionItem(config.target, config.kind);
    item.detail = config.title;
    item.documentation = new vscode.MarkdownString(
        '```ts\n' +
        `${config.subtitle}\n` +
        '```'
    );
    item.insertText = config.insertText;
    item.sortText = '\0';
    item.preselect = true;
    item.filterText = config.target;

    return item;
}